package com.millstein.security.db.mapper;

import com.millstein.security.db.entity.Permission;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface PermissionMapper {

    /**
     * 根据用户id查询它拥有的全新
     * @param userId 用户id
     * @return
     */
    @Select("SELECT p.* FROM `tb_permission` p " +
            "left join `tb_role_permission` rp on p.id = rp.permission_id " +
            "left join `tb_user_role` ur on ur.role_id = rp.role_id " +
            "left join `tb_user` u on u.id = #{userId}")
    List<Permission> selectByUserId(@Param("userId") Long userId);
}
